package com.wpx.batch;

import java.util.HashMap;
import java.util.Map;

public class ExecuteParam {
    private Map<Object, Object> paramsMap = new HashMap<>();

    /**
     * 构造器
     * @param params k v k v k v 成对
     */
    public ExecuteParam(Object... params){
        if(!WpxBatchUtils.isEmpty(params)){
            if(params.length % 2 != 0){
                throw new RuntimeException("参数kv要成对");
            }
            for (int i = 0; i < params.length; i+=2) {
                this.put(params[i], params[i+1]);
            }
        }
    }

    public ExecuteParam put(Object key, Object value){
        this.paramsMap.put(key, value);
        return this;
    }

    public <T> T get(Object key){
        return (T)this.paramsMap.get(key);
    }

}
